#include "MultiCamControl.h"

MultiCamControl::MultiCamControl()
{
	

}

MultiCamControl::~MultiCamControl()
{


}

void MultiCamControl::ResizeCallbackAll(int w, int h)
{
	for( int i = 0; i < cameras.size(); i++ ) {
		cameras[i].ResizeCallbackHandler(w,h);
	}
}

void MultiCamControl::ResizeCallbackOne(int w, int h, int idx)
{
	cameras[idx].ResizeCallbackHandler(w,h);
}

void MultiCamControl::ModelView(int idx) {
	cameras[idx].ModelView();
}

void MultiCamControl::ResetAll()
{
	for( int i = 0; i < cameras.size(); i++ ) {
		cameras[i].ResetPosition();
	}

}

void MultiCamControl::InitCamsUniform(int w, int h)
{
	// place the cameras uniformly distributed about y-axis
	// pointing at the origin
	// slightly up in y coordinate
	int numcam = cameras.size();
	float step = M_PI / numcam;
	float Tup =26.0*2.54;
	float dist = 84.0*2.54;
	float xpos, ypos, zpos;

	xpos = 62.70;
	ypos = 55.74;
	zpos = 54.45;
	float xat = 44.1745;
	float yat = 38.5789;
	float zat = 38.2469;
	float angleOfView = 15.0;

	cameras[0].SetWindowID(1);
	cameras[0].Initialize(xpos,ypos,zpos,xat,yat,zat,1.0,500.0,angleOfView);
	cameras[0].SetViewSize(w,h);

	for( int i = 1; i < numcam; i++ ) {
		float ang = i * step + step/2;
		xpos = dist * cos( ang );
		zpos = dist * sin( ang );
		cameras[i].SetWindowID(i+1);
		cameras[i].Initialize( xpos, Tup, zpos, 0.0, 0.0, 0.0, 1.0, 500.0 );
		cameras[i].SetViewSize(w,h);
		
	}
	
}